# -*- coding: utf-8 -*-


# 基数排序
def radix_sort(array):
    mod, div, most_bit = 10, 1, len(str(max(array)))
    buckets = [[] for x in range(mod)]
    while most_bit:
        for x in array:
            buckets[x // div % mod].append(x)
        i = 0
        for bucket in buckets:
            while bucket:
                array[i] = bucket.pop(0)
                i += 1
        div *= 10
        most_bit -= 1


arr = [54, 47, 7131, 942, 3431, 85, 223, 11]
print(arr)
radix_sort(arr)
print(arr)
